//
//  GKZYModifyUserInformationView.m
//  GKZYAid
//
//  Created by lanou3g on 16/3/14.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYModifyUserInformationView.h"

#define LTVIEW_X self.frame.size.width * 0.15
#define LTVIEW_WIDTH self.frame.size.width * 0.7
#define LTVIEW_HEIGHT self.frame.size.height * 0.05
#define GAP self.frame.size.height * 0.03
#define NUM 101

@implementation GKZYModifyUserInformationView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.imageV = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.imageV.image = [UIImage imageNamed:@"modifyInformation"];
    self.imageV.userInteractionEnabled = YES;
    [self addSubview:self.imageV];
    
    //头像
    self.userHeadPortrait = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * 0.35, self.frame.size.height * 0.05 + 44, self.frame.size.width * 0.3, self.frame.size.width * 0.3)];
    self.userHeadPortrait.layer.masksToBounds = YES;
    self.userHeadPortrait.layer.cornerRadius = self.frame.size.width * 0.15;
    self.userHeadPortrait.backgroundColor = [UIColor orangeColor];
    self.userHeadPortrait.userInteractionEnabled = YES;
    [self.imageV addSubview:self.userHeadPortrait];
    
    //分割线
    self.viewCutOffRule = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.userHeadPortrait.frame) + GAP, self.frame.size.width, 1)];
    self.viewCutOffRule.backgroundColor = [UIColor lightGrayColor];
    [self.imageV addSubview:self.viewCutOffRule];
    
    //ScrollView
    self.scrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.viewCutOffRule.frame), self.frame.size.width, self.frame.size.height)];
    self.scrollV.contentSize = CGSizeMake(0, self.frame.size.height * 1.5);
    [self.imageV addSubview:self.scrollV];
    
    //昵称
    self.userName = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X,GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userName setLabelText:@"昵称:" textFieldPlaceholder:@"请输入昵称" isCiphertext:NO textFieldTag:(self.userName.frame.origin.y + NUM)];
    [self.scrollV addSubview:self.userName];
    
    //性别
    self.userSex = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userName.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userSex setLabelText:@"性别:" textFieldPlaceholder:@"请输入性别" isCiphertext:NO textFieldTag:(self.userSex.frame.origin.y + NUM)];
    [self.scrollV addSubview:self.userSex];
    
    //年龄
    self.userAge = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userSex.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userAge setLabelText:@"年龄:" textFieldPlaceholder:@"请输入年龄" isCiphertext:NO textFieldTag:(self.userAge.frame.origin.y + NUM)];
    [self.scrollV addSubview:self.userAge];
    
    //星座
    self.userSign = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userAge.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userSign setLabelText:@"星座:" textFieldPlaceholder:@"请输入星座" isCiphertext:NO textFieldTag:(self.userSign.frame.origin.y + NUM)];
    [self.scrollV addSubview:self.userSign];
    
    //理想大学
    self.userIdeal = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userSign.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userIdeal setLabelText:@"理想大学:" textFieldPlaceholder:@"请输入理想大学" isCiphertext:NO textFieldTag:(self.userIdeal.frame.origin.y + NUM)];
    [self.scrollV addSubview:self.userIdeal];
    
    //座右铭Label
    self.labelMotto = [[UILabel alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userIdeal.frame) + GAP, LTVIEW_WIDTH * 0.3, LTVIEW_HEIGHT)];
    self.labelMotto.text = @"座右铭:";
    self.labelMotto.font = [UIFont systemFontOfSize:15.0];
    self.labelMotto.backgroundColor = [UIColor clearColor];
    [self.scrollV addSubview:self.labelMotto];
    
    //座右铭TextView
    self.textViewMotto = [[UITextView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.labelMotto.frame), self.labelMotto.frame.origin.y, LTVIEW_WIDTH * 0.7, self.labelMotto.frame.size.height * 2)];
    self.textViewMotto.text = @"请输入座右铭";
    self.textViewMotto.textColor = [UIColor lightGrayColor];
    self.textViewMotto.font = [UIFont systemFontOfSize:17.0f];
    self.textViewMotto.layer.masksToBounds = YES;
    self.textViewMotto.layer.borderWidth = 0.8;
    self.textViewMotto.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.textViewMotto.layer.cornerRadius = 5;
    self.textViewMotto.tag = self.labelMotto.frame.origin.y + NUM;
    self.textViewMotto.backgroundColor = [UIColor clearColor];
    [self.scrollV addSubview:self.textViewMotto];
    
    //保存按钮
    self.buttonSave = [UIButton buttonWithType:UIButtonTypeCustom];
    self.buttonSave.frame = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.textViewMotto.frame) + GAP, LTVIEW_WIDTH, self.scrollV.frame.size.height * 0.07);
    [self.buttonSave setTitle:@"保存" forState:UIControlStateNormal];
    [self.buttonSave setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.buttonSave.backgroundColor = [UIColor orangeColor];
    [self.scrollV addSubview:self.buttonSave];
}

- (void)textField:(UITextField *)textField setTextFieldText:(NSString *)text
{
    textField.text = text;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
